package com.zlp.netty.component;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufAllocator;
import io.netty.buffer.CompositeByteBuf;

import static jdk.nashorn.internal.runtime.regexp.joni.Config.log;

/**
 * @author: zhulaiping
 * @time: 2022/9/6 10:50
 */
public class NettyByteBufDemoComposite {



    //Composite:将几个小的ByteBuf组合成一个新的ByteBuf
    public static void main(String[] args) {
        ByteBuf buffer = ByteBufAllocator.DEFAULT.buffer();
        buffer.writeBytes(new byte[]{1,2,3,4,5});
        ByteBuf buffer1 = ByteBufAllocator.DEFAULT.buffer();
        buffer.writeBytes(new byte[]{6,7,8,9,0});

        CompositeByteBuf byteBufs = ByteBufAllocator.DEFAULT.compositeBuffer();
        byteBufs.addComponents(true,buffer,buffer1);
        NettyBufDemo2.log(byteBufs);
    }
}
